package org.zhuxian.cn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.zhuxian.cn.entity.EquipmentBuildsLike;

@Mapper
public interface EquipmentBuildsLikeMapper extends BaseMapper<EquipmentBuildsLike> {
    
    /**
     * 查询用户是否点赞了指定配装
     * @param buildId 配装ID
     * @param userId 用户ID
     * @return 点赞记录，如果未点赞则返回null
     */
    @Select("SELECT * FROM equipment_builds_like WHERE build_id = #{buildId} AND user_id = #{userId}")
    EquipmentBuildsLike findByBuildIdAndUserId(@Param("buildId") Integer buildId, @Param("userId") Long userId);
    
    /**
     * 统计配装的点赞数
     * @param buildId 配装ID
     * @return 点赞数
     */
    @Select("SELECT COUNT(*) FROM equipment_builds_like WHERE build_id = #{buildId}")
    Integer countByBuildId(@Param("buildId") Integer buildId);
}